<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台管理</title>
    <link rel="icon" href="{{ url_for('static', filename='images/favicon.ico') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='sidebar.css') }}">
    <!-- 新增图表库引用 -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
    <div class="topbar">
        <div class="time-display">
            <span id="current-time">Loading...</span>
        </div>
        <span id="system-runtime">Loading...</span>
    </div>
    <div class="sidebar">
        <ul>
            <li><a class="sidebar-link active" data-target="home" href="#">首页</a></li>
            <!-- 删除: <li><a class="sidebar-link" data-target="api-management" href="#">百度地图API管理</a></li> -->
            <li><a class="sidebar-link" data-target="api-log" href="#">日志管理</a></li>
            <li><a class="sidebar-link" data-target="database-management" href="#">后端数据库管理</a></li>
        </ul>
    </div>
    <div class="divider"></div>
    <div class="content-container">
        <div class="content active" id="home-content">
            <div class="home-container" style="display: flex; flex-wrap: wrap; gap: 20px;">
                <div class="session-count-block block">
                    <h3>当前会话数</h3>
                    <div class="session-value" id="sessionCount">0</div>
                </div>
                <div class="service-list-block block">
                    <h3>服务监控</h3>
                    <ul id="serviceList"></ul>
                </div>
            </div>
        </div>
        <!-- 删除: <div class="content" id="api-management-content">...</div> -->
        <div class="content" id="api-log-content">
            <div class="log-header">
                <div class="log-count" style="backdrop-filter: blur(10px); padding: 10px; border-radius: 4px; margin-right: 15px;">
                    当前日志条数：0
                </div>
                <button class="download-btn" style="background: rgba(0,0,0,0.1); padding: 8px 15px; border-radius: 4px; margin-right: 15px;">
                    下载日志
                </button>
                <button class="clear-btn" style="background: rgba(255,0,0,0.2); color: red; padding: 8px 15px; border-radius: 4px;">
                    清空
                </button>
            </div>
            <div class="log-content" style="height: 60vh; overflow-y: auto; margin-top: 20px; padding: 15px; background: rgba(255,255,255,0.9); backdrop-filter: blur(12px);">
                <ul class="log-display-area" id="logContent"></ul>
            </div>
        </div>
        <div class="content" id="database-management-content">
            <div class="database-management">
                <h2>Redis数据库配置</h2>
                <div class="database-form">
                    <label for="redis_host">Redis主机:</label>
                    <input type="text" id="redis_host" name="redis_host" value="localhost">
                    <label for="redis_port">Redis端口:</label>
                    <input type="text" id="redis_port" name="redis_port" value="6379">
                    <label for="redis_db">Redis数据库:</label>
                    <input type="text" id="redis_db" name="redis_db" value="0">
                    <button id="update-redis-btn">更新Redis配置</button>
                    <div id="redis-status"></div>
                </div>
            </div>
        </div>
    </div>

    <script src="{{ url_for('static', filename='script.js') }}" defer></script>
    <script src="{{ url_for('static', filename='sidebar.js') }}" defer></script>
    <script src="{{ url_for('static', filename='home.js') }}" defer></script>
    <script src="{{ url_for('static', filename='log.js') }}" defer></script> <!-- 新增引入log.js -->
    <!-- 图表初始化脚本 -->
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const ctx = document.getElementById('sessionChart').getContext('2d');
            new Chart(ctx, {
                type: 'line',
                data: {
                    labels: ['10:00', '10:15', '10:30', '10:45', '11:00'],
                    datasets: [{
                        label: '当前会话数',
                        data: [25, 30, 40, 35, 50],
                        borderColor: '#007bff',
                        fill: false
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false
                }
            });
        });
    </script>
</body>
</html>









